package com.wicket.okrapp.biz.service.nb;

import cn.hutool.core.util.ObjectUtil;
import com.wicket.okrapp.biz.service.dto.common.PicMultipleSetDataEntryDto;
import com.wicket.okrapp.common.util.CommonFunctionHelper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrapp.biz.service.dto.req.ImplementPicSingleSetDataEntryReqDto;
import com.wicket.okrapp.biz.service.dto.res.ImplementPicSingleSetDataEntryRespDto;
import com.wicket.okrapp.biz.service.dto.req.ImplementPicMultipleSetDataEntryReqDto;
import com.wicket.okrapp.biz.service.dto.res.ImplementPicMultipleSetDataEntryRespDto;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
public class NbDataSetSingleEntry {
/**
      * code:objectToData
      * name:M执行图片单条转数据集
      * desc:undefined
      * gen by moon at 11/29/2023, 9:31:49 PM
      * 
      **/
     @Trace(operationName = "M执行图片单条转数据集")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementPicSingleSetDataEntryRespDto implementPicSingleSetDataEntry(ImplementPicSingleSetDataEntryReqDto reqDto) {
         ImplementPicSingleSetDataEntryRespDto retData = new ImplementPicSingleSetDataEntryRespDto();
         if(ObjectUtil.isEmpty(reqDto) || ObjectUtil.isEmpty(reqDto.getDatasetField())){
             return retData;
         }
         String[] fileList = reqDto.getDatasetField().split(",");
         if(ObjectUtil.isEmpty(fileList)){
             return retData;
         }
         List<String> retList = Arrays.asList(fileList);
         List<String> retNewList = new ArrayList<>();
         for(String one : retList){
             if(one.equals("--")){
                 continue;
             }
             retNewList.add(CommonFunctionHelper.getFilePath(one));
         }
         retData.setPicSingleSetDataEntryList(retNewList);
         return retData;
      }
/**
      * code:objectToData
      * name:M3执行图片多条转数据集
      * desc:undefined
      * gen by moon at 12/5/2023, 12:23:54 AM
      *
      **/
     @Trace(operationName = "M3执行图片多条转数据集")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementPicMultipleSetDataEntryRespDto implementPicMultipleSetDataEntry(ImplementPicMultipleSetDataEntryReqDto reqDto) {
         ImplementPicMultipleSetDataEntryRespDto retData = new ImplementPicMultipleSetDataEntryRespDto();
         for(PicMultipleSetDataEntryDto one : reqDto.getPicMultipleSetDataEntryList()){
             String dataField = one.getDatasetField();
             List<String> dataList = Arrays.asList(dataField.split(","));
             for(String subOne : dataList){
                 if(subOne.equals("--")){
                     continue;
                 }
                 PicMultipleSetDataEntryDto elm = new PicMultipleSetDataEntryDto();
                 elm.setCycleStageDataId(one.getCycleStageDataId());
                 elm.setDatasetField(CommonFunctionHelper.getFilePath(subOne));
                 retData.getPicMultipleSetDataEntryList().add(elm);
             }
         }
        return retData;
      }
  //手工接入方法
}
